#include <iostream>
#include <jansson.h>
#include <streambuf>
#include <string.h>
#include <vector>
#include "utils.h"

using namespace std;

void test_o_O() {
	json_t* ret;
	//ret = json_pack("{s:o, s:O, s:O}");
	ret = json_pack("{s:s, s:s?, s:s*}",
			"name", NULL,
			"age", NULL,
			"gender", NULL
			);

	if (ret) {
		const char* r = json_dumps(ret, JSON_INDENT(4));
		cout << r <<endl;
		json_decref(ret);
	}else {
		cout << "json_pack return NULL" <<endl;
	}
}

void test_strlen() {
	char a[] = {'a', 'b', 'c', '\0', 'd'};
	cout << strlen(a) << endl;
}

void test_base64_decode()
{
	string data = "brian ";

	string out;
	cout << Base64::EncodedLength(data) <<endl;
	cout << Base64::EncodedLength(6) << endl;
	Base64::Encode(data, &out);
	cout << out << endl;

	string dec;
	Base64::Decode(out, &dec);
	cout << dec << endl;

}

void test_65536() {
	//vector<char> mIn;
	string mIn;
	const char* a = "helloworld";
	const char* b = "niubi";

	//mIn = vector<char>(a, a+10);
	mIn = string(a, a+10);
	//mIn.insert(mIn.end(), b, b+5);
	mIn += b;

	cout << mIn.data() << endl;
	cout << sizeof(a) << endl;
	cout << strlen(a) << endl;
}


int main() {

	//test_o_O();

	//test_strlen();
	//test_base64_decode();
	test_65536();

	return 0;
}
